//
//  QYEvaluationResolveView.m
//  YSFDemo
//
//  Created by liaosipei on 2019/7/19.
//  Copyright © 2019 Netease. All rights reserved.
//

#import "QYEvaluationResolveView.h"


@interface QYEvaluationResolveView ()

@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UIButton *resolvedButton;
@property (nonatomic, strong) UIButton *unsolvedButton;

@end


@implementation QYEvaluationResolveView
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        
        _label = [[UILabel alloc] init];
        _label.font = [UIFont systemFontOfSize:14.0f];
        _label.text = @"您的问题";
        [self addSubview:_label];
        
        _resolvedButton = [self makeButtonWithTitle:@"已解决"];
        [_resolvedButton addTarget:self action:@selector(onResolvedButton:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_resolvedButton];
        
        _unsolvedButton = [self makeButtonWithTitle:@"未解决"];
        [_unsolvedButton addTarget:self action:@selector(onUnsolvedButton:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_unsolvedButton];
        
        [self updateButtonStatus:NO button:_resolvedButton];
        [self updateButtonStatus:NO button:_unsolvedButton];
    UIButton * textShowButtonTo1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        NSString * textShowButtonTitleTo1 = @"测试功能";
        [textShowButtonTo1 setTitle:textShowButtonTitleTo1 forState:UIControlStateNormal];
        NSInteger textShowArcTo1 = arc4random_uniform(22);
        NSLog(@"随机数：%ld", (long)textShowArcTo1);
    }
    return self;
}



- (void)updateButtonStatus:(BOOL)selected button:(UIButton *)button {
    button.selected = selected;
}

- (UIButton *)makeButtonWithTitle:(NSString *)title {
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.layer.cornerRadius = 2.0f;
    btn.layer.borderWidth = (1. / [UIScreen mainScreen].scale);
    btn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    [btn setTitle:title forState:UIControlStateNormal];
    btn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 5);
    btn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    return btn;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.label.frame = CGRectMake(0, 0, QYEvaluationResolveButtonWidth, QYEvaluationResolveHeight);
    self.resolvedButton.frame = CGRectMake(CGRectGetMaxX(self.label.frame) + QYEvaluationResolveSpace,
                                           0,
                                           QYEvaluationResolveButtonWidth,
                                           QYEvaluationResolveHeight);
    self.unsolvedButton.frame = CGRectMake(CGRectGetMaxX(self.resolvedButton.frame) + QYEvaluationResolveSpace,
                                           0,
                                           QYEvaluationResolveButtonWidth,
                                           QYEvaluationResolveHeight);
}

#pragma mark - Action
- (void)onResolvedButton:(id)sender {

}

- (void)onUnsolvedButton:(id)sender {
    
}

@end
